import type { RowType } from '#/views/${frontEndPath}/${businessPath}/${businessPath}.data';

import { requestClient } from '#/api/request';

export namespace ${ClassName}TableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
}

/**
 * 懒加载列表查询
 * : 如果pid为空则查询所有父级,反之查询子级数据
 *
 * @param testTree 测试树对象
 * @return 测试树列表
 */
export async function ${className}QueryLazyListApi(
  params: ${ClassName}TableApi.RowTypeFetchParams,
) {
  return requestClient.get('/${modulePath}/${businessPath}/queryLazyList', { params });
}

/**
 * 列表查询
 *  :结果支持两种结构。1.平级('flat') 2.层级('layer')
 *  :需要再请求头中传入key为: model= 'flat' | 'layer'，默认 'layer'
 *
 * @param testTree 测试树对象
 * @return 测试树列表: 结果支持两种结构。1.平级('flat') 2.层级('layer')
 */
export async function ${className}QueryListApi(params: ${ClassName}TableApi.ListFetchParams) {
  return requestClient.get('/${modulePath}/${businessPath}/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function ${className}QueryByIdApi(params: ${ClassName}TableApi.IdFetchParams) {
  return requestClient.get('/${modulePath}/${businessPath}/queryById', { params });
}

/**
 * 新增
 */
export async function ${className}AddApi(params: ${ClassName}TableApi.RowTypeFetchParams) {
  return requestClient.post('/${modulePath}/${businessPath}/add', params);
}

/**
 * 编辑
 */
export async function ${className}EditApi(params: ${ClassName}TableApi.RowTypeFetchParams) {
  return requestClient.post('/${modulePath}/${businessPath}/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function ${className}DelApi(id) {
  return requestClient.delete<boolean>(`/${modulePath}/${businessPath}/delete/${delParams}`);
}
